package com.tianma315.admin.product.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.tianma315.admin.common.base.CoreServiceImpl;
import com.tianma315.admin.product.vo.ComplaintVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.tianma315.admin.product.dao.ComplaintDao;
import com.tianma315.admin.product.domain.ComplaintDO;
import com.tianma315.admin.product.service.ComplaintService;

import java.util.Date;
import java.util.List;

/**
 * 
 * <pre>
 * 投诉信息
 * </pre>
 * <small> 2019-07-15 17:14:02 | wen</small>
 */
@Service
public class ComplaintServiceImpl extends CoreServiceImpl<ComplaintDao, ComplaintDO> implements ComplaintService {

    @Autowired
    private ComplaintDao complaintDao;

    @Override
    public Page<ComplaintVO> getComplaintVOPage(Integer pageNumber, Integer pageSize, ComplaintVO complaintDO) {
        Page<ComplaintVO> page = new Page<>(pageNumber,pageSize);
        List<ComplaintVO> list = complaintDao.getComplaintDOPage(page,complaintDO);
        page.setRecords(list);
        return page;
    }

    @Override
    public Boolean addComplaint(ComplaintDO complaintDO) {
        complaintDO.setState(0);
        complaintDO.setCreateDate(new Date());
        Boolean result = insert(complaintDO);
        return result;
    }

    @Override
    public Boolean deleteComplaint(Integer complaintId) {
        ComplaintDO complaintDO = new ComplaintDO();
        complaintDO.setState(1);
        complaintDO.setComplaintId(complaintId);
        Boolean result = updateById(complaintDO);
        return result;
    }
}
